fix(branch): add MERGING to BranchStatus enum (infrahub#9293)#1036
Merged
Conversation
The server-side BranchStatus enum gained MERGING in Infrahub 1.9.3 (PR opsmill/infrahub#9116) but the SDK enum was not updated. Any branch returned with status="MERGING" — including a branch stranded in that state by a task worker dying mid-merge — caused client.branch.all() to raise ValidationError, which crashloops the task worker on every sync_remote_repositories run. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Deploying infrahub-sdk-python with
|
| Latest commit: |
a7a0a94
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8f51021b.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://phill-20260519-add-merging-b.infrahub-sdk-python.pages.dev |
…string
ty rejects passing str where BranchStatus is annotated; switch to
BranchData.model_validate({...}) which mirrors how the SDK actually
parses server JSON in branch.py.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## stable #1036 +/- ##
=======================================
Coverage 81.54% 81.54%
=======================================
Files 134 134
Lines 11467 11468 +1
Branches 1735 1735
=======================================
+ Hits 9351 9352 +1
Misses 1569 1569
Partials 547 547
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
ajtmccarty
reviewed
May 19, 2026
…orten note - Drop test_branch_data_accepts_all_server_statuses: per review, the enum-coverage test belongs in the infrahub community repo where it can iterate over the actual server-side BranchStatus enum instead of a hardcoded list of strings. It will be added there as part of the PR that bumps the SDK commit pin. - Rename changelog +branchstatus-merging.fixed.md → 1037.fixed.md to link it to the newly-filed SDK-side issue #1037 (migrated from opsmill/infrahub#9293). - Shorten changelog note per review. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ajtmccarty
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MERGINGtoinfrahub_sdk.branch.BranchStatusso the SDK enum matches the server-sidebackend/infrahub/core/branch/enums.pyenum (which gainedMERGINGin Infrahub 1.9.3 via greater rollback coverage of merge logic infrahub#9116).client.branch.all()raisespydantic_core.ValidationErrorfor any branch returned withstatus="MERGING", which crashloopsinfrahub-task-workeron everysync_remote_repositoriesrun if a merge task dies mid-flight and leaves a branch stranded inMERGING.This patches the SDK side of the bug only — the server-side robustness improvements (guaranteeing a branch never stays in
MERGING, or makingBranchManager.all()tolerant of one malformed entry) are out of scope here and would land inopsmill/infrahub.Reproduction (live, against Infrahub 1.9.5)
Test plan
pytest tests/unit/sdk/test_branch.py— 12 passed.infrahub-task-worker:1.9.5image), patched in-container viadocker cp,client.branch.all()now returns theMERGINGbranch.opsmill/infrahubas part of the PR that bumps the SDK commit pin (per review feedback) — that side can iterate the actual server-sideBranchStatusenum.Follow-ups (separate PRs / not in this changeset)
opsmill/infrahub: bumppython_sdksubmodule pin once this is merged, target a 1.9.6 patch release; add the parametrized enum-coverage test there.opsmill/infrahub: wrap_do_merge_branchbody intry/finallyso a worker death between theMERGINGtransition andMERGED/rollback can't permanently strand a branch.opsmill/infrahub: optionally haveBranchManager.all()skip+log malformed entries rather than failing the whole collection.